<?php

require_once('BaseModel.php');

class Privilegios extends BaseModel{
	protected $_name = "usuarios_privilegios";

	public function getByNivel( $nivel ){
		if($nivel){
			$select = $this->select()->where("nivel = ?", $nivel);
			
			$data = $this->fetchAll( $select );
			if( $data )
				$data = $data->toArray();

			$privilegios = array();
			foreach( $data as $d ){
				$privilegios[] = $d['regra'];	
			}
			return $privilegios;
		}
		return NULL;
	}

	public function getByNivelWithModules( $nivel ){
		if($nivel){
			$select = $this->select()->where("nivel = ?", $nivel);

			$data = $this->fetchAll( $select );
			if( $data )
				$data = $data->toArray();

			return $data;
		}
		return NULL;
	}
}


